console.log("定义变量");

let a = 123;
a = "hello"; 
console.log(a);

console.log("定义常量");
const b = 123;
//b = "hello"; 
console.log(b);

console.log("数据类型");
console.log(typeof b);//number (int or float)
console.log(typeof a);//string
console.log(typeof true);//boolean bool(0/1)
let c;
console.log(typeof c);//undefined 未定义
console.log(typeof null);//null 但输出object 不是空指针 而就是"空值"
console.log(typeof Math);//object 对象 类?
console.log(typeof 123n);//bigint 高精度整数
console.log(typeof Symbol());//symbol 独一无二的值

console.log("显式类型转换");
console.log((10.01).toString());
console.log(String(null));
console.log(Number("10.01"));
console.log(Number("10px"));//not a number
console.log(parseFloat("10.015px").toFixed(2));
console.log(parseInt("10.01px"));
console.log(Number(undefined));
console.log(Number(null));
console.log(Number(true));
console.log(Number(" -2"));
console.log(Number("_"));

console.log(Boolean(-1111));
console.log(Boolean(0));
console.log(Boolean(" "));
console.log(Boolean(null));
console.log(Boolean(undefined));

console.log("隐式类型转换");
//toString
console.log("114513" + 123 + "丁真");
console.log(1 + 123 + "丁真");
//toNumber + - * / % 算数运算符 >= <= > < == != 比较运算符
console.log("4" - 2);
console.log("1[4" - 2);//NaN NaN参与运算 结果也是NaN
console.log(null - 2);
console.log("" == false);
console.log("" === false);

//toBoolean && || ! 逻辑运算符
console.log(0 || null || "abc");//找到第一个真值
console.log("abc" || 0 || null);//找到第一个真值
console.log(undefined || false || null);//找不到取最后
console.log("abc" && 123 && null);//找到第一个假值
console.log("abc" && 123 && 1);//找不到取最后